<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::get('/install',function(){
    return 'installed';
    \App\Models\Role::create(['name'=>'系统管理员','permissions'=>'{}']);
    \App\Models\Role::create(['name'=>'高管','permissions'=>'{}']);
    \App\Models\Role::create(['name'=>'客户经理','permissions'=>'{}']);
    //安装用户数据
    factory(\App\Models\User::class, 50)->create();
    return 'installed';
});

//登录
Route::post('/api/auth/login','AuthenticateController@authenticate');
//刷新token
Route::post('/api/auth/refresh-token','AuthenticateController@refreshToken')->middleware(['jwt.refresh']);


Route::group(['middleware'=>'jwt.auth'],function(){
    Route::resource('/api/basedatas','BaseDataController');
    Route::resource('/api/roles','RoleController');

    Route::post('/api/sale_intentions/assign/{id}','SaleIntentionController@assignUser');
    Route::post('/api/sale_intentions/custom_dev_result/{id}','SaleIntentionController@customDevResult');
    Route::resource('/api/sale_intentions','SaleIntentionController');

    Route::resource('/api/users','UserController');
    Route::resource('/api/custom_dev_plans','CustomDevPlanController');
    Route::resource('/api/customs','CustomController');
    Route::resource('/api/contacts','ContactController');
    Route::resource('/api/visits','VisitController');
    Route::resource('/api/orders','OrderController');
    Route::resource('/api/order_items','OrderItemController');
    Route::resource('/api/custom_services','CustomServiceController');
});
